package com.example.windowdemo.window.vistor;

import android.content.Context;
import android.view.WindowManager;

import com.example.windowdemo.callback.WindowVisitorCallBack;
import com.example.windowdemo.threadpool.WindowVisitorThreadPool;

/**
 * @author: njb
 * @date: 2023/8/3 11:25
 * @desc:
 */
public class WindowVisitorImpl implements WindowVisitorCallBack {
    private WindowVisitorThreadPool threadPool;

    public WindowVisitorImpl() {
        threadPool = new WindowVisitorThreadPool();
    }

    public void shutdown() {
        threadPool.shutdown();
    }

    @Override
    public void visit(WindowVisitor<?> window) {
        WindowManager windowManager = (WindowManager) window.context.getSystemService(Context.WINDOW_SERVICE);
        windowManager.addView(window.contentView, window.layoutParams);
    }
}
